import request from "@/utils/request";
import type { GetUserList, UserItem } from "./model/userModel";

enum Api {
  getUserListUrl = "/admin/acl/user",
  addUserListUrl = "/admin/acl/user/save",
  updateListUrl = "/admin/acl/user/update",
  deleUserListUrl = "/admin/acl/user/remove",
}

//获取用户列表
export const getUserListApi = (page: number, limit: number) => {
  return request.get<any, GetUserList>(
    Api.getUserListUrl + `/${page}/${limit}`
  );
};

//添加用户接口函数
export const addUserListApi = (
  username: string,
  nickName: string,
  password: string
) => {
  return request.post<any, null>(Api.addUserListUrl, {
    username,
    nickName,
    password,
  });
};

//修改用户接口函数
export const updateListApi = (
  username: string,
  nickName: string,
  id: string
) => {
  return request.put<any, null>(Api.updateListUrl, {
    username,
    nickName,
    id,
  });
};

//删除用户接口函数
export const deleUserListApi = (id: string) => {
  return request.delete<any, null>(Api.deleUserListUrl + `/${id}`);
};
